function Output_signal = Function_Phy_OFDM_Modulate_per_Subframe(NSLsymb, NFFT, cpLen0, cpLenR, NRBsc, NSLRB, input_signal)
%phy_ofdm_modulate_per_subframe creates time-domain waveform for
%transmission (36.211, 9.9).
% Inputs: 
%   conf: struct containing the following phy configuration related
%   fields: NSLsymb, NFFT, cpLen0, cpLenR, NRBsc
%   input_signal : the freq-domain signal (time-frequency grid)
Output_signal = zeros(2*NSLsymb*NFFT + 2*cpLen0 + 2*(NSLsymb-1)*cpLenR, 1);

tmp = zeros(NFFT,1);
counter = 1;
for ll = 1 :2*NSLsymb
    if ll == 1 || ll == NSLsymb + 1
        cp = cpLen0;
    else
        cp = cpLenR;
    end
    % zero stuff:
    tmp((NFFT-NSLRB*NRBsc)/2+1:NFFT-(NFFT-NSLRB*NRBsc)/2) = input_signal(:,ll);
    % IFFT
    Tmp = ifft(ifftshift(tmp));
    % Normalize power:
    Tmp = NFFT/sqrt(NSLRB*NRBsc)*Tmp;
    % Add CP:
    Tmp = [Tmp(end-cp+1:end); Tmp]; %#ok<AGROW>
    % Shift by half subcarrier:
    Tmp = Tmp.*exp(2i*pi*(-cp:NFFT-1)'/NFFT/2);

    Output_signal(counter : counter - 1 + NFFT + cp) = Tmp;
    counter = counter + NFFT + cp;
end
